/**
 * 项目示例-列表综合搜索
 * Date 2023-5-25 09:33:56
 * {
 *   label: '', 筛选项名称
 *   prop: '', 筛选项字段
 *   type: '', 组件类型（'input' | 'select' | 'inputNumber' | 'cascader' | 'datePicker' | 'timePicker' | 'timeSelect' | 'treeSelect' | 'checkbox' | 'radio'）
 *   defaultValue: '', 筛选项默认值（不写默认undefined）
 *   inputProps: {}, 过滤组件属性，跟`ElementPlus`对应组件的`#Attributes`相同
 *   events: {} 仅支持change事件
 * }
 */
import type { FilterItem } from '@/components/FilterBar/types'
export const areaOptions: FilterItem[] = [
  {
    label: '区域名称：',
    prop: 'areaName',
    type: 'input',
    span: 24,
    inputProps: {
      placeholder: '请输入区域名称'
    }
  },
  {
    label: '绘制区域：',
    prop: 'drawArea',
    type: 'inputBtn',
    defaultValue: '',
    isDisabled: true,
    span: 24,
    icon: 'Crop',
    inputProps: {
      placeholder: '请框选地图坐标'
    },
    events: {
      click: (value: any, evt: any) => {
        console.log(value, evt)
      }
    }
  },
  {
    label: '是否允许进入：',
    prop: 'isEnter',
    type: 'radio',
    span: 14,
    defaultValue: '',
    inputProps: {
      options: [
        { label: '是', value: 'Y' },
        { label: '否', value: 'N' }
      ]
    },
    events: {
      change: (value: any, evt: any) => {
        console.log(value, evt)
      }
    }
  },
  {
    label: '手推车最低阈值：',
    prop: 'minValue',
    type: 'inputNumber',
    controlsPosition: 'right',
    isDisabled: false,
    span: 24,
    inputProps: {
      placeholder: '',
      min: 1
    },
    defaultValue: 1,
    events: {
      change: (value: any, evt: any) => {
        console.log(value, evt)
      }
    }
  },
  {
    label: '允许进入手推车：',
    prop: 'allowEnter',
    filterable:true,
    type: 'select',
    multiple: true,
    isDisabled: false,
    span: 24,
    inputProps: {
      max:2,
      placeholder: '',
      options: [
        { label: '全部', value: 'ALL' },
        { label: 'A401', value: 'A401' },
        { label: 'A402', value: 'A402' },
        { label: 'A403', value: 'A403' }
      ]
    },
    events: {
      change: (value: any, evt: any) => {
        if(value.toString().indexOf('ALL') > -1){
          let values:string[] = []
          for(let item of areaOptions[4].inputProps.options){
            if(item.value != 'ALL'){
              values.push(item.value);
            }
          }
          evt.setFieldsValue({ allowEnter: values })
        }
        
      }
    }
  }
]
export const trolleyOptions: FilterItem[] = [
  {
    label: '区域名称',
    prop: 'areaName',
    type: 'input',
    suffixIcon: 'Search',
    span: 24,
    inputProps: {
      placeholder: '请输入区域名称'
    }
  },
  {
    label: '手推车编号',
    prop: 'trolleyNo',
    type: 'input',
    span: 24,
    suffixIcon: 'Search',
    inputProps: {
      placeholder: '请输入手推车编号'
    }
  },

  {
    label: '类型',
    prop: 'type',
    filterable:true,
    type: 'select',
    defaultValue: '',
    span: 14,
    inputProps: {
      options: [
        { label: '全部', value: '' },
        { label: '禁入区', value: 'N' },
        { label: '准入区', value: 'Y' }
      ]
    },
    events: {
      change: (value: any, evt: any) => {
        console.log(value, evt)
      }
    }
  }
]
